#ifndef FDC_H
#define FDC_H

//timeout is 2 seconds
#define FDC_TIMEOUT				200

#define FDC_SPECIFY				0x03
#define FDC_CHECK_STATUS		0x04
#define FDC_WRITE_DATA			0x45
#define FDC_READ_DATA			0x46
#define FDC_READ_TRACK			0x42
#define FDC_RECALIBRATE			0x07
#define FDC_SENSE_INTERRUPT	0x08
#define FDC_READ_ID				0x4A
#define FDC_DUMP_REGS			0x0E
#define FDC_CONFIGURE			0x13
#define FDC_SEEK					0x0F

typedef struct
{
	u16int status_main;			// read only
	u16int status_a;				// read only
   u16int status_b;				// read only

	u16int digital_input;		// read only
   u16int digital_output;
	
   u16int tape_drive;

	u16int data_rate_select;	// write only
   u16int config_control;		//write only
	u16int data_fifo;

}fdc_ports_t;

typedef struct
{
	u32int id;
	u32int index;

	u32int cylinders;
   u32int heads;
   u32int sectors;

	u32int current_cylinder;
   u32int current_head;
   u32int current_sector;

	u32int step_rate_time;
	u32int head_load_time;
	u32int head_unload_time;
	u32int motor_delay;

	u32int motor_on;

	fdc_ports_t ports;

	u8int buffer[1024];//a 1 megabyte buffer (transfer area / cache)
}fdc_drive_t;

void init_fdc(void);

int fdc_read(fdc_drive_t *fd, u8int *data, u32int sector, u32int offset, u32int length);

void init_fdc_interface(void);
#endif
